package com.wksc.demo.authority.security;

import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

@Service("userDetailsSecurityService")
public class UserDetailsSecurityService implements UserDetailsService {
    @Override
    public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException {
        return null;
    }

//    @Autowired
//    private UserService service;
//
//    @Override
//    public CurSessionUser loadUserByUsername(String userName) throws UsernameNotFoundException {
//        Assert.notNull(userName, "the login user name must not be null");
//        CurSessionUser user = service.getUserForLogin(userName);
//
//        if (user == null) {
//            throw new UsernameNotFoundException("user not found");
//        }
//
//        List<GrantedAuthority> authList = new ArrayList<GrantedAuthority>();
//
//        if (user.getStatus() == SystemConst.STATUS.LOCKING.getValue()) {
//            authList.add(new SimpleGrantedAuthority("ROLE_LOCK"));
//        } else {
//            authList.add(new SimpleGrantedAuthority("ROLE_USER"));
//            for (String auth : user.getAuthorityCodes()) {
//                authList.add(new SimpleGrantedAuthority(auth));
//            }
//        }
//
//        CurSessionUser curSessionUser = new CurSessionUser(user.getUsername(), user.getPassword(), authList);
//        curSessionUser.setupCurSessionUser(user);
//
//        return curSessionUser;
//    }
//
//    public static void main(String[] args) {
//        Md5PasswordEncoder md5PasswordEncoder = new Md5PasswordEncoder();
//        md5PasswordEncoder.setIterations(4);
//        String pwd = md5PasswordEncoder.encodePassword("123456", "admin");
//        System.out.println(pwd);
//        System.out.println(Integer.MAX_VALUE);
//        System.out.println(SqlUtils.formatLikeParam("%a%"));
//    }
}